package com.yzf.demo.demo.Thread.lock;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Created by 于占峰 on 2020/4/4/004.
 */
public class ConditionDemo {

    public static void main(String[] args) {
        Lock lock = new ReentrantLock();//创建一个重入锁
        Condition condition = lock.newCondition();//使用锁new
        //创建两个线程 并让两个线程使用同一个锁和Condition Condition才能生效
        ConditionDemoWait conditionDemoWait = new ConditionDemoWait(lock, condition);
        ConditionDemoNotify conditionDemoNotify = new ConditionDemoNotify(lock, condition);
        conditionDemoWait.start();
        conditionDemoNotify.start();
    }
}
